<template>
	<view>
		<index v-if="PageCur=='index'" @toCenter="toCenter" @toQuant="toQuant"></index>
		<quantization v-if="PageCur=='quantization'" @toCenter="toCenter"></quantization>
		<deal v-if="PageCur=='deal'"></deal>
		<asset v-if="PageCur=='asset'"></asset>
		<my v-if="PageCur=='my'"></my>

		<view class="box">
			<view class="cu-bar tabbar bg-white shadow foot">
				<view class="action" @click="NavChange" data-cur="index">
					<view class='cuIcon-cu-image'>
						<image v-if="PageCur=='index'" src="../../static/tabBar/index_cur.png"></image>
						<image v-if="PageCur != 'index'" src="../../static/tabBar/index.png"></image>
					</view>
					<view :class="PageCur=='index'?'color_main':'text-gray'">首页</view>
				</view>

				<view class="action" @click="NavChange" data-cur="asset">
					<view class='cuIcon-cu-image'>
						<!-- <view class="cu-tag badge">{{message}}</view> -->
						<image v-if="PageCur=='asset'" src="../../static/tabBar/order_cur.png"></image>
						<image v-if="PageCur != 'asset'" src="../../static/tabBar/order.png"></image>
					</view>
					<view :class="PageCur=='asset'?'color_main':'text-gray'">资讯</view>
				</view>
				

				<view @click="NavChange" class="action text-gray add-action" data-cur="deal">
					<image class="logo_btn" mode="widthFix" src="../../static/logo.png"></image>
					<view :class="PageCur=='deal'?'color_main':'text-gray'">交易</view>
				</view>

				<view class="action" @click="NavChange" data-cur="quantization">
					<view class='cuIcon-cu-image'>
						<image v-if="PageCur=='quantization'" src="../../static/tabBar/shop_cur.png"></image>
						<image v-if="PageCur != 'quantization'" src="../../static/tabBar/shop.png"></image>
					</view>
					<view :class="PageCur=='quantization'?'color_main':'text-gray'">量化</view>
				</view>

				<view class="action" @click="NavChange" data-cur="my">
					<view class='cuIcon-cu-image'>
						<!-- <view class="cu-tag badge">红点</view> -->
						<image v-if="PageCur=='my'" src="../../static/tabBar/me_cur.png"></image>
						<image v-if="PageCur != 'my'" src="../../static/tabBar/me.png"></image>
					</view>
					<view :class="PageCur=='my'?'color_main':'text-gray'">我的</view>
				</view>

			</view>
		</view>

	</view>
</template>

<script>
	import index from "../coin/index.vue";	//首页
	// import index from "../home/home.vue";	//首页
	import quantization from "../coin/quantization.vue";	// 量化
	import deal from "../coin/deal.nvue";	// 交易
	// import asset from "../coin/asset.vue";	//资产
	import asset from "../coin/news.vue";	//资讯
	import my from "../coin/center.vue";	//我的
	export default {
		components: {
			index,
			quantization,
			deal,
			asset,
			my
		},
		data() {
			return {
				PageCur: 'asset',

				message: '0',
				openId:'',
				access_token:'',
				
				tip:"我是提示",
				duration:1

			};
		},
		created() {
			
		},
		// 分享小程序
		onShareAppMessage(res) {
			return {
				title: '分享小程序',
			};
		},
		onLoad() {
			//获取退出时的tabbar记录
			/* uni.getStorage({
				key: 'PageCur',
				success: function(res) {
				    this.PageCur = res.data;
				},
				fail: function(res) {}
			}); */
		},
		methods: {
			toCenter(){
				this.PageCur = 'my'
			},
			toQuant(e){
				console.log('toQuant',e)
				this.PageCur = 'quantization'
			},
			NavChange: function(e) {
				console.log(e.currentTarget.dataset.cur)

				this.PageCur = e.currentTarget.dataset.cur;

				if (this.PageCur == 'index') {
					document.title = '首页'
				} else if (this.PageCur == 'quantization') {
					document.title = '量化'
				} else if (this.PageCur == 'cases') {
					document.title = '交易'
				} else if (this.PageCur == 'news') {
					document.title = '资产'
				} else if (this.PageCur == 'me') {
					document.title = '我的'
				}

				/* uni.setStorage({
					key: 'PageCur',
					data: this.PageCur,
					success: function() {
						console.log('保存成功！');
					}
				}); */
			},
			NavChange_xd: function() {
				uni.navigateTo({
					url: 'publish',
					animationType: 'slide-in-bottom',
					animationDuration: 200
				});
			}
		}
	}
</script>

<style lang="scss">
	.box {
		background-color: #101334;
		margin: 20upx 0;
	}
	.box view.cu-bar {
		background-color: #101334;
		color: aliceblue;
		margin-top: 20upx;
	}
	
	.logo_btn{
		width: 38*2rpx;
		height: 38*2rpx;
		position: absolute;
		z-index: 2;
		border-radius: 50%;
		top: -40rpx;
		left: 0rpx;
		right: 0;
		margin: auto;
		padding: 0;
	}
	.cu-bar.tabbar .action.add-action {
	    padding-top: 56rpx !important;
	}
</style>
